package controller;

import service.Checkout_recordsService;
import service.impl.Checkout_recordsServiceimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

@WebServlet(urlPatterns = "/Checkout_recordsController")
public class Checkout_recordsController extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        req.setCharacterEncoding("utf-8");
        String op=req.getParameter("op");
        HttpSession session=req.getSession(true);
        PrintWriter out=resp.getWriter();
        if(op.equals("add")){
          String studentId=req.getParameter("studentId");
          String reasonType=req.getParameter("reasonType");
          String detail=req.getParameter("detail");
            Checkout_recordsService che=new Checkout_recordsServiceimpl();
            try {
                che.add(studentId,reasonType,detail);
            } catch (SQLException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
